package com.probox.common.core.annotation;

/**
 * 参考系统提供的校验注解可知，message，groups，payload这3个属性必须提供
 *
 * @Constraint(validatedBy = CanNotHaveBlankValidator.class)指定该注解的校验类
 */


import com.probox.common.core.validator.CanEditNotHaveBlankValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;


/**
 * @author panmou
 * @date 2022-05-18
 * 用于实现不包含空格的,和字符限制的注解
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
//指定了当前注解使用哪个校验类来进行校验。
@Constraint(validatedBy = {CanEditNotHaveBlankValidator.class})
public @interface CanEditNotHaveBlank {
    //默认错误消息
    String message() default "";

    int min() default 0;

    int max() default 0;

    //分组
    Class<?>[] groups() default {};

    //负载
    Class<? extends Payload>[] payload() default {};

    //指定多个时使用
    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface List {
        CanEditNotHaveBlank[] value();
    }

}
